package com.zhxy.util.thread;

import java.util.concurrent.TimeoutException;

public class WaitObject {

	public void await(long timeout) throws InterruptedException,
			TimeoutException {
		
		long time = System.currentTimeMillis();
		synchronized (this) {
			wait(timeout);
		}
		
		if (time + timeout > System.currentTimeMillis()) {
			// 超时
			throw new TimeoutException();
		}
	}
}
